﻿using System;
using UnityEngine;

public class Action2010 : GameAction {
    private ActionResult actionResult;

    public Action2010 ( )
        : base(2010) {
    }

    protected override void SendParameter (NetWriter writer, ActionParam actionParam) {
    }

    protected override void DecodePackage (NetReader reader) {
        actionResult = new ActionResult( );
        actionResult["UserId"] = reader.getInt( );
        actionResult["NextUserId"] = reader.getInt( );
        actionResult["DeckType"] = reader.getWORD( );
        actionResult["CardSize"] = reader.getInt( );

        int subRecordCount = reader.getInt( );
        ActionResult[] subTable = new ActionResult[subRecordCount];
        for (int i = 0; i < subRecordCount; i++) {
            ActionResult subRecord = new ActionResult( );
            reader.recordBegin( );
            subRecord["CardId"] = reader.getInt( );
            reader.recordEnd( );
            subTable[i] = subRecord;
        }
        actionResult["Children_1"] = subTable;
        actionResult["IsReNew"] = reader.getByte( );
        actionResult["MultipleNum"] = reader.getInt( );
        actionResult["AnteNum"] = reader.getInt( );
        actionResult["IsAI"] = reader.getByte( );

        int subRecordCount2 = reader.getInt( );
        ActionResult[] subTable2 = new ActionResult[subRecordCount2];
        for (int i = 0; i < subRecordCount2; i++) {
            var subRecord = new ActionResult( );
            reader.recordBegin( );
            subRecord["UserId"] = reader.getInt( );

            int subRecordCount_1 = reader.getInt( );
            ActionResult[] subTable_1 = new ActionResult[subRecordCount_1];
            int r = 0;
            for (r = 0; r < subRecordCount_1; r++) {
                var subRecord_1 = new ActionResult( );
                reader.recordBegin( );
                subRecord_1["CardId"] = reader.getInt( );
                reader.recordEnd( );
                subTable_1[r] = subRecord_1;
            }
            subTable2 = subTable_1;
            reader.recordEnd( );
            subTable2[r] = subRecord;
        }
        actionResult["Children_1"] = subTable2;

    }

    public override ActionResult GetResponseData ( ) {
        return actionResult;
    }
}